package top.laoshuzi.designpatterns.base.structure.composite;

/**
 * 组合部件
 */
public class Unit implements Component {

    private String name;

    public Unit(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void add(Component component) throws Exception {
        throw new Exception("Unit无法添加");
    }

    @Override
    public void remove(Component component) throws Exception {
        throw new Exception("Unit无法删除");
    }

    @Override
    public String toString() {
        return "Unit{" +
                "name='" + name + '\'' +
                '}';
    }
}
